{{include file="public/header" /}}

<!-- right content start  -->
<div class="content-right">
    <div class="content">
        <legend>
            <span class="fs-16">用户优惠劵管理</span>
            <a href="{{:PluginsAdminUrl('coupon', 'admin', 'index')}}" class="fr fs-14 m-t-5 am-icon-mail-reply"> 返回</a>
        </legend>

        <div class="user-content">
            <!-- form start -->
            <form class="am-form form-validation form-search" method="post" action="{{:PluginsAdminUrl('coupon', 'user', 'index')}}" request-type="form">
                <div class="thin">
                    <div class="am-input-group am-input-group-sm am-fl so">
                        <input type="text" autocomplete="off" name="keywords" class="am-radius" placeholder="用户名/昵称/手机/邮箱" value="{{if !empty($params.keywords)}}{{$params.keywords}}{{/if}}" />
                        <span class="am-input-group-btn">
                            <button class="am-btn am-btn-default am-radius" type="submit" data-am-loading="{spinner:'circle-o-notch', loadingText:'搜索中...'}">搜索</button>
                        </span>
                    </div>
                    <label class="am-fl thin_sub more-submit">
                        更多筛选条件
                        {{if isset($params['is_more']) and $params['is_more'] eq 1}}
                            <input type="checkbox" name="is_more" value="1" id="is_more" checked />
                            <i class="am-icon-angle-up"></i>
                        {{else /}}
                            <input type="checkbox" name="is_more" value="1" id="is_more" />
                            <i class="am-icon-angle-down"></i>
                        {{/if}}
                    </label>
                </div>
                <table class="so-list more-where {{if !isset($params['is_more'])}}none{{/if}}">
                    <tbody>
                        <tr>
                            <td>
                                <span>卡劵：</span>
                                <select name="coupon_id" class="chosen-select" data-placeholder="优惠劵...">
                                    <option value="-1">优惠劵...</option>
                                    {{if !empty($coupon_list)}}
                                        {{foreach $coupon_list as $v}}
                                            <option value="{{$v.id}}" {{if isset($params['coupon_id']) and $params['coupon_id'] eq $v['id']}}selected{{/if}}>{{$v.name}}</option>
                                        {{/foreach}}
                                    {{/if}}
                                </select>
                            </td>
                            <td>
                                <span>状态：</span>
                                <select name="is_valid" class="chosen-select" data-placeholder="是否有效...">
                                    <option value="-1">是否有效...</option>
                                    {{if !empty($common_is_whether_list)}}
                                        {{foreach $common_is_whether_list as $v}}
                                            <option value="{{$v.value}}" {{if isset($params['is_valid']) and $params['is_valid'] eq $v['value']}}selected{{/if}}>{{$v.name}}</option>
                                        {{/foreach}}
                                    {{/if}}
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <span>过期：</span>
                                <select name="is_expire" class="chosen-select" data-placeholder="是否过期...">
                                    <option value="-1">是否过期...</option>
                                    {{if !empty($common_is_whether_list)}}
                                        {{foreach $common_is_whether_list as $v}}
                                            <option value="{{$v.value}}" {{if isset($params['is_expire']) and $params['is_expire'] eq $v['value']}}selected{{/if}}>{{$v.name}}</option>
                                        {{/foreach}}
                                    {{/if}}
                                </select>
                            </td>
                            <td>
                                <span>使用：</span>
                                <select name="is_use" class="chosen-select" data-placeholder="是否使用...">
                                    <option value="-1">是否使用...</option>
                                    {{if !empty($common_is_whether_list)}}
                                        {{foreach $common_is_whether_list as $v}}
                                            <option value="{{$v.value}}" {{if isset($params['is_use']) and $params['is_use'] eq $v['value']}}selected{{/if}}>{{$v.name}}</option>
                                        {{/foreach}}
                                    {{/if}}
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td class="time">
                                <span>时间：</span>
                                <span>
                                    <input type="text" autocomplete="off" name="time_start" class="am-form-field am-input-sm am-radius Wdate" placeholder="有效起始时间" value="{{if !empty($params.time_start)}}{{$params.time_start}}{{/if}}" data-validation-message="有效起始时间格式有误" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'yyyy-MM-dd'})" autocomplete="off" /><i class="am-icon-calendar"></i>
                                </span>
                                <em class="text-grey">~</em>
                                <span>
                                    <input type="text" autocomplete="off" name="time_end" class="am-form-field am-input-sm am-radius Wdate" placeholder="有效结束时间" value="{{if !empty($params.time_end)}}{{$params.time_end}}{{/if}}" pattern="^[0-9]{4}-[0-9]{2}-[0-9]{2}$" data-validation-message="有效结束时间格式有误" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'yyyy-MM-dd'})" autocomplete="off" /><i class="am-icon-calendar"></i>
                                </span>
                            </td>
                            <td class="time">
                                <span>时间：</span>
                                <span>
                                    <input type="text" autocomplete="off" name="add_time_start" class="am-form-field am-input-sm am-radius Wdate" placeholder="添加起始时间" value="{{if !empty($params.add_time_start)}}{{$params.add_time_start}}{{/if}}" data-validation-message="添加起始时间格式有误" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'yyyy-MM-dd'})" autocomplete="off" /><i class="am-icon-calendar"></i>
                                </span>
                                <em class="text-grey">~</em>
                                <span>
                                    <input type="text" autocomplete="off" name="add_time_end" class="am-form-field am-input-sm am-radius Wdate" placeholder="添加结束时间" value="{{if !empty($params.add_time_end)}}{{$params.add_time_end}}{{/if}}" pattern="^[0-9]{4}-[0-9]{2}-[0-9]{2}$" data-validation-message="添加结束时间格式有误" onclick="WdatePicker({firstDayOfWeek:1,dateFmt:'yyyy-MM-dd'})" autocomplete="off" /><i class="am-icon-calendar"></i>
                                </span>
                            </td>
                        </tr>
                        <tr>
                            <td></td>
                            <td>
                                <button type="submit" class="am-btn am-btn-secondary am-radius am-btn-xs btn-loading-example" data-am-loading="{spinner:'circle-o-notch', loadingText:'搜索中...'}">搜索</button>
                                <a href="{{:PluginsAdminUrl('coupon', 'user', 'index')}}" class="am-btn am-btn-warning am-radius am-btn-sm reset-submit">清除条件</a>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </form>
            <!-- form end -->

            <!-- 列表 -->
            <table class="am-table am-table-striped am-table-hover m-t-10">
                <thead>
                    <tr>
                        <th>用户信息</th>
                        <th class="am-hide-sm-only">优惠劵名称</th>
                        <th class="am-hide-sm-only">是否有效</th>
                        <th class="am-hide-md-down">是否使用</th>
                        <th class="am-hide-md-down">是否过期</th>
                        <th class="am-hide-md-down">过期时间</th>
                        <th>更多</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    {{if !empty($data_list)}}
                        {{foreach $data_list as $v}}
                            <tr id="data-list-{{$v.id}}" {{if $v['is_valid'] eq 0}}class="am-active"{{/if}}>
                                <td class="user-info">
                                    {{if !empty($v['user'])}}
                                        <img src="{{$v.user.avatar}}" alt="{{$v.user.user_name_view}}" class="am-img-thumbnail am-radius am-align-left" />
                                        <ul class="user-base">
                                            <li>名称：{{if empty($v['user']['username'])}}<span class="cr-ccc">未填写</span>{{else /}}{{$v.user.username}}{{/if}}</li>
                                            <li>昵称：{{if empty($v['user']['nickname'])}}<span class="cr-ccc">未填写</span>{{else /}}{{$v.user.nickname}}{{/if}}</li>
                                            <li>手机：{{if empty($v['user']['mobile'])}}<span class="cr-ccc">未填写</span>{{else /}}{{$v.user.mobile}}{{/if}}</li>
                                            <li>邮箱：{{if empty($v['user']['email'])}}<span class="cr-ccc">未填写</span>{{else /}}{{$v.user.email}}{{/if}}</li>
                                        </ul>
                                    {{else /}}
                                        用户信息异常
                                    {{/if}}
                                </td>
                                <td class="am-hide-sm-only">{{$v.coupon_name}}</td>
                                <td class="am-hide-sm-only">
                                    <a href="javascript:;" class="am-icon-btn am-icon-check submit-state {{if $v['is_valid'] eq 1}}am-success{{else /}}am-default{{/if}}" data-url="{{:PluginsAdminUrl('coupon', 'user', 'statusupdate')}}" data-id="{{$v.id}}" data-state="{{$v['is_valid']}}" data-is-update-status="1" data-field="is_valid"></a>
                                </td>
                                <td class="am-hide-md-down">
                                    {{$v.is_use_name}}
                                    {{if $v['is_use'] eq 1}}
                                        <br /><span class="am-badge am-badge-success am-radius">{{$v.use_time_text}}</span>
                                    {{/if}}
                                </td>
                                <td class="am-hide-md-down">
                                    <span class="{{if $v['is_expire'] eq 1}}am-text-danger{{/if}}">{{$v.is_valid_name}}</span>
                                </td>
                                <td class="am-hide-md-down">
                                    <span class="{{if $v['is_expire'] eq 1}}am-text-danger{{/if}}">
                                        {{$v.time_start_text}}<br />
                                        {{$v.time_end_text}}
                                    </span>
                                </td>
                                <td>
                                    <span class="am-icon-caret-down c-p" data-am-modal="{target: '#my-popup{{$v.id}}'}"> 查看更多</span>
                                    <div class="am-popup am-radius" id="my-popup{{$v.id}}">
                                        <div class="am-popup-inner">
                                            <div class="am-popup-hd">
                                                <h4 class="am-popup-title">详情内容</h4>
                                                <span data-am-modal-close
                                                class="am-close">&times;</span>
                                            </div>
                                            <div class="am-popup-bd">
                                                <dl class="dl-content">
                                                    <dt>用户信息</dt>
                                                    <dd class="user-info">
                                                        {{if !empty($v['user'])}}
                                                            <img src="{{$v.user.avatar}}" alt="{{$v.user.user_name_view}}" class="am-img-thumbnail am-radius am-align-left" />
                                                            <ul class="user-base">
                                                                <li>名称：{{if empty($v['user']['username'])}}<span class="cr-ccc">未填写</span>{{else /}}{{$v.user.username}}{{/if}}</li>
                                                                <li>昵称：{{if empty($v['user']['nickname'])}}<span class="cr-ccc">未填写</span>{{else /}}{{$v.user.nickname}}{{/if}}</li>
                                                                <li>手机：{{if empty($v['user']['mobile'])}}<span class="cr-ccc">未填写</span>{{else /}}{{$v.user.mobile}}{{/if}}</li>
                                                                <li>邮箱：{{if empty($v['user']['email'])}}<span class="cr-ccc">未填写</span>{{else /}}{{$v.user.email}}{{/if}}</li>
                                                            </ul>
                                                        {{else /}}
                                                            用户信息异常
                                                        {{/if}}
                                                    </dd>

                                                    <dt>优惠劵名称</dt>
                                                    <dd>{{$v.coupon_name}}</dd>

                                                    <dt>是否有效</dt>
                                                    <dd>{{$v.is_valid_name}}</dd>

                                                    <dt>是否使用</dt>
                                                    <dd>
                                                        {{$v.is_use_name}}
                                                        {{if $v['is_use'] eq 1}}
                                                            <span class="am-badge am-badge-success am-radius">{{$v.use_time_text}}</span>
                                                        {{/if}}
                                                    </dd>

                                                    <dt>是否过期</dt>
                                                    <dd>{{$v.is_expire_name}}</dd>

                                                    <dt>过期时间</dt>
                                                    <dd>
                                                        <span class="am-badge am-radius">{{$v.time_start_text}} ~ {{$v.time_end_text}}</span>
                                                    </dd>

                                                    <dt>添加时间</dt>
                                                    <dd>{{$v.add_time_text}}</dd>

                                                    <dt>更新时间</dt>
                                                    <dd>{{$v.upd_time_text}}</dd>
                                                </dl>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <button class="am-btn am-btn-danger am-btn-xs am-radius am-icon-trash-o submit-delete" data-url="{{:PluginsAdminUrl('coupon', 'user', 'delete')}}" data-id="{{$v.id}}"> 删除</button>
                                </td>
                            </tr>
                        {{/foreach}}
                    {{/if}}
                </tbody>
            </table>

            {{if empty($data_list)}}
                <div class="table-no"><i class="am-icon-warning"></i> 没有相关数据</div>
            {{/if}}

            <!-- 分页 -->
            {{if !empty($data_list)}}
                {{$page_html|raw}}
            {{/if}}
        </div>
    </div>
</div>
<!-- right content end  -->
        
<!-- footer start -->
{{include file="public/footer" /}}
<!-- footer end -->